﻿import QtQuick 2.0

Item {
    width: 240
    height: 50
    property int sceneIndex
    property string sceneName
    property int checkState  // 0： 未检查， 1：检查中， 2：检查完成
    property int preCheckState: 0  // 0:未检查   1:异常   2:正常

    signal sceneSelect()

    Column{
        spacing: checkState == 1 ? 9 : 5
        anchors.bottom: parent.bottom
        Row{
            spacing: 5
            anchors.horizontalCenter: parent.horizontalCenter
            Image{
                id: checkBoxIcon
                source: "qrc:/imgs/checkbox-ok.png"
                visible: checkState==2 ? true : false
                anchors.bottom: parent.bottom
                anchors.bottomMargin: 4
            }

            Text{
                id: sceneNameText
                text: sceneName
                color: Qt.rgba(1,1,1,0.5)
                font{
                    family: "Microsoft YaHei"
                    pixelSize: 23
                    bold: checkState==1
                }
            }
        }

        Rectangle{
            id: sceneRect
            width: 240
            height: checkState == 1 ? 10 : 6
            color: "#7FF2F2F2"
        }
    }

    MouseArea{
        anchors.fill: parent
        onClicked: {
            sceneSelect()
        }
    }

    onCheckStateChanged: {
        if(checkState == 0){
            sceneRect.color = "#7FF2F2F2"
            sceneNameText.color = "#7FF2F2F2"
        }
        else if(checkState == 1){
            sceneRect.color = "#2D8CFE"
            sceneNameText.color = "#2D8CFE"
        }
        else if(checkState == 2){
            if(preCheckState == 1){
                checkBoxIcon.source = ""
                checkBoxIcon.source = "qrc:/imgs/checkbox-not-ok.png"
                sceneRect.color = "#F05252"
                sceneNameText.color = "#F05252"
            }else if(preCheckState == 2){
                checkBoxIcon.source = ""
                checkBoxIcon.source = "qrc:/imgs/checkbox-ok.png"
                sceneRect.color = "#00D160"
                sceneNameText.color = "#00D160"
            }
        }
    }
}
